package com.gerfmarquez.creadormusica;

import android.app.Activity;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
import android.view.View;

import com.gerfmarquez.creadormusica.utilities.Constants;
import com.gerfmarquez.creadormusica.utilities.Utilities;

public class CreadorMusicaActivity extends Activity 
{
    static final String TAG="CreadorMusicaActivity";


    float increment; 
    byte []sonidoA = null;

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        sonidoA = Utilities.getInstance().getBytesFromFile("a", this.getApplicationContext());
    	
        

        	
//        	track.stop();
//        	new Thread() {
//        		public void run() {
//        		}
//        	}.start();

        
        
//        SoundPool sp = new SoundPool(2,AudioManager.STREAM_MUSIC, 0);
//        
//        sp.

        


    }
    
    public void reproducir(View view) {
    	switch (view.getId())  {
    	case  R.id.button1:
//    		track.write(sonidoWav, 0, sonidoWav.length);
//    		reproducirNotaEspecifica();
    	}
    }
    
//    public void reproducirNotaEspecifica() {
//    	track.flush();
//    	track.write(nuevoArray, 0, nuevoArray.length);
//    	track.reloadStaticData();
//    	Log.d(TAG, "Play State: "+track.getPlayState());
//    	sonidoA = Utilities.getInstance().getBytesFromFile("b", this.getApplicationContext());
//    	track.stop(); //order matters in this two invocations
//    	track.reloadStaticData();
//    	int result = track.write(sonidoA, 0, sonidoA.length);
//    	Log.d(TAG, "Result of writing audio: "+result);
//    	track.play();
//    	Log.d(TAG, "Play State: "+track.getPlayState());
//    }
}
